package com.xuanwu.mall.goods.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xuanwu.mall.goods.entity.PmsBrand;
import com.xuanwu.mall.goods.service.IPmsBrandService;
import com.xuanwu.mall.util.common.RespResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * xuanwu-mall
 * com.xuanwu.mall.goods.controller
 *
 * @Description:品牌 前端控制器
 * @Author：xuanwudeshuijngye_26567
 * @Date 2024-03-15 10:58
 * @Company: 旋舞科技有限公司
 **/
@RestController
@RequestMapping("/pmsBrand")
public class PmsBrandController {

    @Autowired
    private IPmsBrandService iPmsBrandService;

    @PostMapping("/addPmsBrand")
    public RespResult addPmsBrand(@RequestBody PmsBrand brand) {
        iPmsBrandService.save(brand);
        return RespResult.defaultSuccessResult();
    }

    @PutMapping("/updatePmsBrand")
    public RespResult updatePmsBrand(@RequestBody PmsBrand brand) {
        iPmsBrandService.updateById(brand);
        return RespResult.defaultSuccessResult();
    }

    @DeleteMapping("/{id}")
    public RespResult deletePmsBrand(@PathVariable(value = "id") Long id) {
        iPmsBrandService.removeById(id);
        return RespResult.defaultSuccessResult();
    }

    @PostMapping("/queryBrandByCondition")
    public RespResult<List<PmsBrand>> queryBrandByCondition(@RequestBody PmsBrand brand) {
        List<PmsBrand> list = iPmsBrandService.queryBrandByCondition(brand);
        return RespResult.successResult(list);
    }

    @PostMapping("/queryBrandByConditionWithPage/{pageNum}/{pageSize}")
    public RespResult<Page<PmsBrand>> queryBrandByConditionWithPage(@PathVariable(value = "pageNum") Long pageNum,@PathVariable(value = "pageSize") Long pageSize, @RequestBody PmsBrand brand) {
        Page<PmsBrand> brandPage = iPmsBrandService.queryBrandByConditionWithPage(brand, pageNum, pageSize);
        return RespResult.successResult(brandPage);
    }
}
